load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:defs.bzl", "rust_test_suite_with_extra_srcs")

package(default_visibility = [
    "//rs/p2p/test_utils:__subpackages__",
    "//rs/replica:__subpackages__",
])

DEPENDENCIES = [
    # Keep sorted.
    "//rs/http_endpoints/async_utils",
    "//rs/interfaces",
    "//rs/monitoring/logger",
    "//rs/monitoring/metrics",
    "//rs/p2p/quic_transport",
    "//rs/protobuf",
    "//rs/types/base_types",
    "@crate_index//:axum",
    "@crate_index//:bytes",
    "@crate_index//:futures",
    "@crate_index//:prometheus",
    "@crate_index//:prost",
    "@crate_index//:rand",
    "@crate_index//:slog",
    "@crate_index//:thiserror",
    "@crate_index//:tokio",
    "@crate_index//:tokio-metrics",
    "@crate_index//:tokio-util",
    "@crate_index//:zstd",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/p2p/memory_transport",
    "//rs/p2p/test_utils",
    "//rs/state_manager",
    "//rs/test_utilities/logger",
    "//rs/types/types",
    "//rs/types/types_test_utils",
    "@crate_index//:mockall",
    "@crate_index//:turmoil",
]

MACRO_DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:async-trait",
]

ALIASES = {}

rust_library(
    name = "state_sync_manager",
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_name = "ic_state_sync_manager",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.9.0",
    deps = DEPENDENCIES,
)

rust_test(
    name = "state_sync_manager_tests",
    size = "small",
    crate = ":state_sync_manager",
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_test_suite_with_extra_srcs(
    name = "state_sync_manager_integration",
    srcs = ["tests/test.rs"],
    aliases = ALIASES,
    extra_srcs = ["tests/common.rs"],
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = [":state_sync_manager"] + DEPENDENCIES + DEV_DEPENDENCIES,
)
